import { RouteRecordRaw, createRouter, createWebHistory } from 'vue-router';
import BaseLayout from '/@/layout/BaseLayout.vue';

// 固定路由
export const constantRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('/@/views/login/index.vue'),
  },
  {
    path: '/403',
    name: '403',
    component: () => import('/@/views/abnormal/403.vue'),
  },
  {
    path: '/404',
    name: '404',
    component: () => import('/@/views/abnormal/404.vue'),
  },
  {
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import('/@/views/abnormal/404.vue'),
  },
];

// 异步路由
export const asyncRoutes = [
  {
    path: '/',
    name: 'Home',
    component: BaseLayout,
    redirect: '/index',
    meta: {
      title: '首页',
      icon: '',
      keepAlive: false,
      requireAuth: false,
    },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('../views/index/index.vue'),
      },
    ],
  },
  {
    path: '/version',
    name: 'Version',
    component: BaseLayout,
    redirect: '/version/home',
    meta: {
      title: '版本',
      icon: '',
      keepAlive: false,
      requireAuth: false,
    },
    children: [
      {
        path: 'home',
        name: 'VersionHome',
        component: () => import('/@/views/version/Home.vue'),
        meta: {
          title: '版本主页',
          icon: '',
          keepAlive: false,
          requireAuth: false,
        },
      },
    ],
  },
];

const routes: RouteRecordRaw[] = [...constantRoutes, ...asyncRoutes];

export default createRouter({
  history: createWebHistory(),
  routes,
  strict: true,
});
